from ChessConsts import ChessConsts

def getValidRookMoves(self,fromPos):
# darren & ronan work in progress

	moves = []        
	dirs = [(1,0),(-1,0),(0,1),(0,-1)]

	moves = self.traceValidMoves(fromPos,dirs)

	moves = self.checkKingGuard(fromPos,moves)

	return moves

def getValidPawnMoves(board, fromPos):
        '''gcoghlan && oxana - working on this one'''
        
        moves = []
        specialMoves = {}
        fx, fy = fromPos
        
        if board._turn == ChessConsts.WHITE:
            movedir = -1
            startrow = 6
            ocol = ChessConsts.BLACK
            eprow = 3
        else:
            movedir = 1
            startrow = 1
            ocol = ChessConsts.WHITE
            eprow = 4
        
        if board.isFree(fx, fy + movedir):
            moves.append((fx, fy + movedir))
            
        if fy == startrow:
            if board.isFree(fx, fy + movedir) and board.isFree(fx, fy + (movedir * 2)):
                moves.append((fx, fy + (movedir * 2)))
                specialMoves[(fx, fy + (movedir * 2))] = board.EP_MOVE
        if fx < 7 and board.getColor(fx + 1, fy + movedir) == ocol:
            moves.append((fx + 1, fy + movedir))
        if fx > 0 and board.getColor(fx - 1, fy + movedir) == ocol:
            moves.append((fx - 1, fy + movedir))
            
        if fy == eprow and board._ep[1] != 0:
            if board._ep[0] == fx + 1:
               moves.append((fx + 1, fy + movedir))
               specialMoves[(fx + 1, fy + movedir)] = board.EP_CAPTURE_MOVE
            if board._ep[0] == fx - 1:
               moves.append((fx - 1, fy + movedir))
               specialMoves[(fx - 1, fy + movedir)] = board.EP_CAPTURE_MOVE

        moves = board.checkKingGuard(fromPos, moves, specialMoves)
         
        return (moves, specialMoves)
